//
//  HLHomeUser.swift
//  weibo-snh
//
//  Created by 黄力 on 15/12/20.
//  Copyright © 2015年 HLTest. All rights reserved.
//

import UIKit

class HLHomeUser: NSObject {
    //用户id
    var id: Int64 = 0
    //昵称
    var name: String?
    //头像
    var avatar_large: String?
    //认证类型
    var verified_type: Int = -1
    //会员等级
    var mbrank: Int = 0
    
    //返回用户头像url的只读属性
    var avatar_URL: NSURL?{
        get {
            return NSURL(string: avatar_large ?? "")
        }
    }
    // 认证类型，-1：没有认证，0，认证用户，2,3,5: 企业认证，220: 达人
    //返回用户认证图片的只读属性
    var verified_Image: UIImage?{
        get {
            //判断
            switch verified_type {
            case -1: return nil
            case 0: return UIImage(named: "avatar_vip")
            case 2,3,5: return UIImage(named: "avatar_enterprise_vip")
            case 220: return UIImage(named: "avatar_grassroot")
            default: return nil
            }
        }
    }
    //范围会员图片的只读属性
    var vipImage: UIImage?{
        get {
            if mbrank == 0 {
                return UIImage(named: "common_icon_membership_expired")
            }
            return UIImage(named: "common_icon_membership_level" + "\(mbrank)")
        }
    }
    
    //字典转模型
    init(dic: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dic)
    }
    //抛出未找到的key
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
}
